/* Vecmath.

   Copyright (C) 2001, 2002, 2003 Stefan Maierhofer.

   Written by Stefan Maierhofer <sm@cg.tuwien.ac.at>

   This file is part of Vecmath.

   Vecmath is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   Vecmath is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with Vecmath; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */

using System;

namespace Vecmath
{

    /// <summary>
    /// Rot2F.
    /// </summary>
    public struct Rot2F
    {

        public static Rot2F Identity = new Rot2F(0);

        public Rot2F(float radians)
        {
            r = radians;
            cos = (float)Math.Cos(radians);
            sin = (float)Math.Sin(radians);
        }

        public Trafo2F ToTrafo2F()
        {
            return new Trafo2F(
                cos, sin, 0,
                -sin, cos, 0,
                0, 0, 1
                );
        }

        public static implicit operator Trafo2F(Rot2F r)
        {
            return r.ToTrafo2F();
        }

        public static Vec2F operator*(Vec2F v, Rot2F r)
        {
            return v * r.ToTrafo2F();
        }

        public static Pnt2F operator*(Pnt2F p, Rot2F r)
        {
            return p * r.ToTrafo2F();
        }

        public static Trafo2F operator*(Shift2F t, Rot2F r)
        {
            return t.ToTrafo2F() * r.ToTrafo2F();
        }

        public static Trafo2F operator*(Scale2F t, Rot2F r)
        {
            return t.ToTrafo2F() * r.ToTrafo2F();
        }

        private float r;
        private float cos;
        private float sin;

    }

}
